package ua.yandex.skipass;


import java.util.Calendar;

public class Terminal {
    private System system;
    private PassChecker passChecker;

    Terminal(System system, PassChecker passChecker) {
        this.passChecker = passChecker;
        this.system = system;
    }
    public boolean allowedToPass(SkiPass skiPass) {
        if (checkPass(skiPass)) {
            system.addOnePassAllow(skiPass.getPassType());
            return true;
        } else {
            system.addOnePassRejection(skiPass.getPassType());
            return false;
        }
    }

    boolean checkPass(SkiPass skiPass) {
        return passChecker.checkPass(skiPass, Calendar.getInstance(), system);
    }
}
